package com.qf.job;


import com.qf.pojo.User;
import com.qf.service.UserService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Random;

public class MyJob implements Job {
    @Autowired
    private UserService userService;


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        System.out.println("quartz执行"+new Date());
        User user = new User();
        Random random = new Random();
        user.setUserName("jim"+ random.nextInt(9999));
        user.setName("JJ"+random.nextInt(9999));
        user.setPassword("123456");
        user.setEmail("qq@qq");
        user.setAge(random.nextInt(200));

        userService.addUser(user);

    }
}
